/*
 	消息帮助类
	@auth 邓柳江
*/
Ext.Loader.setConfig({enabled: true});
var msgCt;
Ext.define('common.msgHelper', {
	requires:[
         'Ext.window.MessageBox',
         'Ext.tip.*'
    ],
    // 构造方法
    constructor: function (config) {
    	if(!msgCt){
            // It's better to create the msg-div here in order to avoid re-layouts 
            // later that could interfere with the HtmlEditor and reset its iFrame.
            msgCt = Ext.DomHelper.insertFirst(document.body, {id:'msg-div'}, true);
        }
    },
    
    statics: {
    	/*
    	 * 渐进渐出消息提示框
    	 */
    	createBox : function (t, s){
            return '<div class="msg"><h3>' + t + '</h3><p>' + s + '</p></div>';
        },
		msg : function(title, content){
            if(!msgCt){
                msgCt = Ext.DomHelper.insertFirst(document.body, {id:'msg-div'}, true);
            }
            var s = Ext.String.format.apply(String, Array.prototype.slice.call(arguments, 1));
            var m = Ext.DomHelper.append(msgCt, this.createBox(title, s), true);
            m.hide();
            m.slideIn('t').ghost("t", { delay: 3500, remove: true});
        },
        
        
        /*
    	 * 模态消息对话框
    	 */
        confirm: function(msg) {
			Ext.MessageBox.confirm('Confirm', msg);
		},
		alert: function(msg) {
			Ext.MessageBox.alert('信息提示框', msg);
		},
		showErrorMsg: function(msg) {
			this.showMsg("error", '错误信息', msg);
		},
		showMsg: function(type, titile, msg) {
			var iconType;
			if (type == 'error') {
				title = 'Error';
				iconType = 'x-message-box-error';
			} else if (type == 'info') {
				title = 'Informational';
				iconType = 'x-message-box-info';
			} else if (type == 'question') {
				title = 'Question';
				iconType = 'x-message-box-question';
			} else if (type == 'warning') {
				title = 'Warning';
				iconType = 'x-message-box-question';
			}
			Ext.MessageBox.show({
	           title: title,
	           msg: msg,
	           buttons: Ext.MessageBox.OK,
	           //fn: showResult,
	           icon: iconType
	       });
		},
		showMsg: function(type,titile, msg, fn) {
			var iconType;
			if (type == 'error') {
				title = 'Error';
				iconType = 'x-message-box-error';
			} else if (type == 'info') {
				title = 'Informational';
				iconType = 'x-message-box-info';
			} else if (type == 'question') {
				title = 'Question';
				iconType = 'x-message-box-question';
			} else if (type == 'warning') {
				title = 'Warning';
				iconType = 'x-message-box-question';
			}
			Ext.MessageBox.show({
	           title: title,
	           msg: msg,
	           buttons: Ext.MessageBox.OK,
	           fn: fn,
	           icon: iconType
	       });
		}
    }
    
    
    
    
});

